﻿using System.Text;
namespace RbmlVisualizer.Data.Blocks
{
    public class ClassifierBlock
    {
        public Classifier Classifier1 { get; set; }

        public Classifier Classifier2 { get; set; }

        public BlockLink Relationship { get; set; }

        public ClassDiagramType ParentDiagramType { get; set; }

        public override string ToString()
        {
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.Append(this.ParentDiagramType);
            stringBuilder.AppendFormat(" {0} -- {1}", Classifier1, Classifier2);
            return stringBuilder.ToString();
        }

        public bool Equals(ClassifierBlock block)
        {
            if (ReferenceEquals(null, block))
            {
                return false;
            }

            if (ReferenceEquals(this, block))
            {
                return true;
            }

            return Equals(block.Classifier1, Classifier1) && Equals(block.Classifier2, Classifier2);
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj))
            {
                return false;
            }

            if (ReferenceEquals(this, obj))
            {
                return true;
            }

            return obj.GetType() == typeof(ClassifierBlock) && Equals((ClassifierBlock)obj);
        }

        public override int GetHashCode()
        {
            unchecked
            {
                return ((Classifier1 != null ? Classifier1.GetHashCode() : 0)*397) ^ (Classifier2 != null ? Classifier2.GetHashCode() : 0);
            }
        }
    }
}
